﻿using AbpIntegrationDemo.Api.Applications.Orders.DataLoaders;
using AbpIntegrationDemo.Api.Applications.Orders.GraphTypes;

namespace AbpIntegrationDemo.Api.Applications.Orders.Queries;

[ExtendObjectType(typeof(OrderGraphType))]
public class OrderExtendQueryResolver
{
    public async Task<OrderLogGraphType?> GetFirstOrderLog([Parent] OrderGraphType order, [Service] OrderLogBatchDataLoader dataLoader)
    {
        var orderLog = await dataLoader.LoadAsync(order.Id);
        return orderLog == null ? null : new OrderLogGraphType()
        {
            Id = orderLog.Id,
            CreateTime = orderLog.CreateTime,
        };
    }
}